package com.example.gridview.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.gridview.R;


public class StaggeredAdapter extends ArrayAdapter<String> {

	private String[]  txtList;
	public StaggeredAdapter(Context context, int textViewResourceId,
			String[] objects) {
		super(context, textViewResourceId, objects);
		txtList = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;

		if (convertView == null) {
			LayoutInflater layoutInflator = LayoutInflater.from(getContext());
			convertView = layoutInflator.inflate(R.layout.row_staggered_demo,
					null);
			holder = new ViewHolder();
			holder.txtView = (TextView)convertView .findViewById(R.id.txtNote);
			convertView.setTag(holder);
		}

		holder = (ViewHolder) convertView.getTag();
		holder.txtView.setText(txtList[position]);

		return convertView;
	}

	static class ViewHolder {
		TextView txtView;
	}
}
